import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:palyer/app/components/custom_app_bar.dart';

import 'package:palyer/app/modules/home/home/controller.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(HomeController());
    return Scaffold(
      key: controller.scaffoldKey,
      appBar: CustomAppBar(
        leading: IconButton(
          icon: const Icon(Icons.menu),
          iconSize: 24,
          onPressed: () {
            controller.scaffoldKey.currentState!.openDrawer();
          },
        ),
        title: const Text('可爱兔'),
        actions: [
          IconButton(
            onPressed: controller.showNotification,
            icon: const Icon(Icons.share),
          ),
          IconButton(
            onPressed: controller.goDrop,
            icon: const Icon(Icons.arrow_drop_down_circle),
          ),
        ],
      ),
      body: Center(
        child: AnimatedTextKit(
          repeatForever: true,
          animatedTexts: controller.text2
              .map((e) => TyperAnimatedText(e,
                  textStyle: TextStyle(
                    fontSize: 32,
                    shadows: [
                      Shadow(
                        blurRadius: 3.0,
                        color: Theme.of(context).primaryColor,
                        offset: const Offset(0, 0),
                      ),
                    ],
                  )))
              .toList(),
          totalRepeatCount: 4,
          pause: const Duration(milliseconds: 2000),
          displayFullTextOnTap: true,
          stopPauseOnTap: true,
        ),
      ),
      drawer: Drawer(
        child: Column(
          children: [
            DrawerHeader(
              decoration: BoxDecoration(
                color: Theme.of(context).primaryColor,
              ),
              child: Center(
                child: ClipOval(
                  child: Image.network(
                    'https://scpic.chinaz.net/files/pic/pic9/202004/zzpic24539.jpg',
                    width: 60,
                    height: 60,
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ),
            ListTile(
              leading: const Icon(Icons.video_collection),
              title: const Text('播放器'),
              onTap: controller.goPlay,
            ),
            ListTile(
              leading: const Icon(Icons.system_security_update),
              title: const Text('系统托盘'),
              onTap: controller.goTray,
            ),
            ListTile(
              leading: const Icon(Icons.arrow_drop_down_circle),
              title: const Text('文件拖动'),
              onTap: controller.goDrop,
            ),
            // 检查更新
            ListTile(
              leading: const Icon(Icons.update),
              title: const Text('检查更新'),
              onTap: controller.checkUpdate,
            ),
            // 主题切换
            ListTile(
              leading: const Icon(Icons.color_lens),
              title: const Text('主题切换'),
              onTap: controller.changeTheme,
            ),
            // unity
            ListTile(
              leading: const Icon(Icons.gamepad),
              title: const Text('excel'),
              onTap: controller.goExcel,
            ),
            ListTile(
              leading: const Icon(Icons.exit_to_app),
              title: const Text('推出登录'),
              onTap: controller.logout,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.add),
        onPressed: () {},
      ),
    );
  }
}
